from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from users import views
from users.views import UserAuthorizeView

urlpatterns = [
    url(r'^test0/$', views.TestView0.as_view()),
    url(r'^test1/$', views.TestView1.as_view()),
    # 检测用户名是否存在路由
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UsernameCountView.as_view()),
    # 检测手机号是否存在路由
    url(r'^usermobile/(?P<mobile>1[3-9]\d{9})/count/$', views.UsermobileCountView.as_view()),
    # 用户注册路由
    url(r'^users/$', views.CreateUserView.as_view()),
    # 登录 obtain_jwt_token: 登录视图(登录接口)
    # url(r'^authorizations/$', obtain_jwt_token),
    url(r'^authorizations/$', UserAuthorizeView.as_view()),
    # 用户详情视图
    url(r'^user/$', views.UserDetailView.as_view()),
    # 修改用户邮箱
    url(r'^email/$', views.EmailView.as_view()),
    # 激活邮箱
    url(r'^email/verification/$', views.VerifyEmailView.as_view()),
    # 保存商品浏览历史
    url(r'^browse_histories/$', views.BrowseHistoryView.as_view()),
]
# 户地址管理
router = DefaultRouter()
router.register(r'addresses', views.AddressViewSet, base_name='addresses')
urlpatterns += router.urls

